<div class="bjui-pageContent">
    <div class="bjui-pageHeader" style="background-color:#fefefe; border-bottom:none;">
        <form data-toggle="ajaxsearch" data-options="{searchDatagrid:$.CurrentNavtab.find('#order-type-lists-table')}">
            <fieldset>
                <legend style="font-weight:normal;">搜索：</legend>
                <div style="margin:0; padding:1px 5px 5px;">

                    <span>名称：</span>
                    <input type="text" name="title" class="form-control" size="30">

                    <div class="btn-group">
                        <button type="submit" class="btn-green" data-icon="search">开始搜索</button>
                        <button type="reset" class="btn-orange" data-icon="times">重置</button>
                    </div>
                </div>
            </fieldset>
        </form>
    </div>
    <button type="button" class="btn-default" data-toggle="dialog" data-options="{
        id:'order-type-add-dialog',
        url:'/admin/order-type/add',
        width:800,
        height:500,
        title:'添加'
    }">
        添加
    </button>
    <button type="button" class="btn-default" data-toggle="dialog" data-options="{
            id:'ordertype-category-dialog',
            url:'/admin/order-type/category-list',
            width:800,
            height:500,
            title:'添加'
        }">
        分类
    </button>
    <table class="table table-bordered" id="order-type-lists-table" data-toggle="datagrid" data-options="{
        height: '85%',
        gridTitle : '工序管理',
        showToolbar: false,
        toolbarItem: 'add',
        editMode: 'dialog',
        local: 'local',
        dataUrl: '/admin/order-type/list',
        editUrl: '/admin/order-type/edit',
        delUrl: '/admin/order-type/del',
        delPK: 'id',
        linenumberAll: true,
        sortAll: false,
        contextMenuH: true,
        contextMenuB: true,
        inlineEditMult: false,
        paging: {selectPageSize:'20,30,50',  pageSize:20},
        showEditbtnscol: false,
        customEditbtns: {width:200,position:'replace'},
        fullGrid: true,
        fieldSortable: false,
        filterThead: false,
        columnMenu: false,
     }">
        <thead>
        <tr>
            <th data-options="{name:'title',align:'center',width:100}">标题</th>
            <th data-options="{name:'category_id',type:'select',items:categoryJson,align:'center',width:100}">分类</th>
            <th data-options="{name:'img_url', render:'get_img_by_path', align:'center'}" data-toggle="webuploader">图片</th>
            <th data-options="{name:'process', edit:false, add:false, render:'get_process', align:'center',width:100}">流程</th>
            <th data-options="{align:'center',width:200,render:process_manage}">管理</th>
        </tr>
        </thead>
    </table>
</div>
<script>
    function get_process(value, data){
        var html = '';
        $(value).each(function(){
            html += ('步骤'+this.pivot.step_number+':'+this.title+'<br>');
        })
        return html;
    }
    function process_manage(value, data){
        var html = '<button type="button" class="btn btn-info" data-toggle="navtab" data-options="{id:\'permission_navtab\',fresh:true, url:\'/admin/order-type/set-process\', title:\'设置流程\', data:{orderTypeId:' + data.id + '}}"><i class="fa fa-sitemap"></i> 设置流程</button>';
        html += '<button type="button" class="btn btn-green" data-toggle="dialog" data-options="{id:\'order-type-edit-dialog\',fresh:true, url:\'/admin/order-type/edit\', title:\'设置流程\',width:800,height:500, data:{orderTypeId:' + data.id + '}}"><i class="fa fa-edit"></i> 编辑</button>';
//        html += ' <button type="button" class="btn btn-red bjui-datagrid-btn delete"><i class="fa fa-remove"></i> 删除</button>';
        html += '<button type="button" class="btn-red" data-toggle="del.datagrid.tr">删除</button>';
        return html
    }

    function datagrid_tree_operation(){
        return ' <button type="button" class="btn btn-red bjui-datagrid-btn delete"><i class="fa fa-remove"></i> 删除</button>'
    }
    function get_img_by_path(value){
        return '<img src="'+value+'" width="100">';
    }

    function categoryJson(){
        return [{!! $categoryListJson !!}]
    }

</script>
